<div class="col-md-2">
    <%= render :partial => "search/nav", :locals => { :section => "search-profiles" } %>
</div>

<div class="col-md-10">
    <div class="container">

      <h2>Search profiles</h2>

      <%= render partial: "search/form", locals: { searchType: "profiles/" } %>

      <div class="row">
        <div class="col-lg-7">
        <% if params[:query].blank?%>
          <p>Please enter a search term.</p>
        <% elsif @profiles.present? %>

          <h4>Results for "<b><%= params[:query] %></b>":</h4>
          <p>Searched profiles by <i>username</i> and <i>bio</i></p>
          <table class="table">
            <tr>
              <th class="d-lg-none"></th>
              <th><a href = "/search/profiles/<%= params[:query] %>?sort=username"> <%= translation('users.list.username') %></a> <i class="fa fa-arrows-v"></i></th>
              <th><a href="/search/profiles/<%= params[:query] %>?sort=last_activity"> <%= translation('users.list.last_activity') %></a> <i class="fa fa-arrows-v"></i></th>
              <th><a href="/search/profiles/<%= params[:query] %>?sort=joined"> <%= translation('users.list.joined') %></a> <i class="fa fa-arrows-v"></i></th>
            </tr>
            <% @profiles.each do |profile| %>
              <tr>
                <td class="d-lg-none" style="padding-top: 16px;">
                  <img class="rounded-circle" id="profile-photo" style="width:40px;margin-right:8px;border: 1px solid lightgrey;" src="<%= profile.profile_image %>" />
                </td>
                <td style="display: flex; align-items: center;">
                  <div class="d-lg-none">
                    <img class="rounded-circle" id="profile-photo" style="width:40px;margin-right:8px;border: 1px solid lightgrey;" src="<%= profile.profile_image %>" />
                  </div>
                  <a style="margin-left: 12px;" href="/profile/<%= profile.username %>"><%= profile.username %></a>
                </td>
                <td style="padding-top:16px;"><%= time_ago_in_words(Time.at(profile.updated_at)) if profile %></td>
                <td style="padding-top:16px;"><%= distance_of_time_in_words(profile.created_at, Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' }) %></td>
              </tr>
            <% end %>
          </table>
        <% else %>
          <p>No results found for "<b><%= params[:query] %></b>" by <i>username</i> or <i>bio</i> :-(</p>
          <p>Try searching <a href="/search/content/<%= params[:query] %>">all content</a></p>
        <% end %>
    </div>
    <div class="col-lg-4 col-lg-offset-1" >
      <% if params[:query].blank? %>
        <p>&nbsp;</p>
      <% elsif @tag_profiles.present?%>
        <h4>Results for "<b><%= params[:query] %></b>":</h4>
        <p>Searched profiles by <i>profile tags</i></p>
        <% @tag_profiles.each do |profile| %>
          <tr><td style="width:40%"><h4><a href= <%= "/profile/#{profile.username}" %> ><%= profile.username %></a><td></h4></tr>
        <% end %>
      <% else %>
        <p>No results found for "<b><%= params[:query] %></b>" by <i>profile tags</i> :-(</p>
        <p>Try searching <a href="/search/content/<%= params[:query] %>">all content</a></p>
      <% end %>
    </div>
    </div>
  </div>
  <% if @pagy %>
    <%= raw  pagy_bootstrap_nav @pagy unless @unpaginated %>
  <% else %>
  <%= will_paginate @profiles, renderer: WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated %>
  <% end %>
</div>
